package icom.acm.bean;
/**
 * @author shench
 */
import icom.acm.util.DBConnect;

import java.util.Date;

public class T_USER {
	private Integer U_ID;			// 编号
	private String U_PASSWORD;		// 密码
	private String U_EMAIL;			// 邮箱
	private String U_NICKNAME;		// 昵称
	private Date U_REGISTERDATE;	// 注册时间
	private Integer U_ROLE;			// 角色
	
	public T_USER(){}
	
	public T_USER(DBConnect db) throws Exception{
		if (db!=null){
			setU_ID(db.getInt("U_ID"));
			setSqlSelectU_PASSWORD(db.getString("U_PASSWORD"));
			setU_EMAIL(db.getString("U_EMAIL"));
			setU_NICKNAME(db.getString("U_NICKNAME"));
			setU_REGISTERDATE(new Date(db.getTimestamp("U_REGISTERDATE").getTime()));
			setU_ROLE(db.getInt("U_ROLE"));
		}
	}
	
	public Integer getU_ROLE() {
		return U_ROLE;
	}
	public void setU_ROLE(Integer u_role) {
		U_ROLE = u_role;
	}
	public Integer getU_ID() {
		return U_ID;
	}
	public void setU_ID(Integer u_id) {
		U_ID = u_id;
	}
	public String getU_PASSWORD() {
		return U_PASSWORD;
	}
	public void setU_PASSWORD(String u_password) {
		u_password = icom.acm.util.locker.Password.MD5(u_password);
		U_PASSWORD = u_password;
	}
	public void setSqlSelectU_PASSWORD(String u_password) {
		U_PASSWORD = u_password;
	}
	public String getU_EMAIL() {
		return U_EMAIL;
	}
	public void setU_EMAIL(String u_email) {
		U_EMAIL = u_email;
	}
	public String getU_NICKNAME() {
		return U_NICKNAME;
	}
	public void setU_NICKNAME(String u_nickname) {
		U_NICKNAME = u_nickname;
	}
	public Date getU_REGISTERDATE() {
		return U_REGISTERDATE;
	}
	public void setU_REGISTERDATE(Date u_registerdate) {
		U_REGISTERDATE = u_registerdate;
	}

	public String toJson() {
		String json = "{";
		json = json + "\"u_id\":\""+U_ID+"\",";
		json = json + "\"u_nickname\":\""+U_NICKNAME+"\",";
		json = json + "\"u_email\":\""+U_EMAIL+"\"";
		
		json = json + "}";
		return json;
	}

}
